package com.admin.service;

import com.admin.bean.GoodSoftware;
import com.admin.bean.GoodSoftwareType;
import com.admin.dbdao.GoodSoftwareDao;
import com.data.util.DatabaseIdUtils;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * 精选软件的服务层
 *
 * @author:HingLo
 * @create 2017-10-09 11:11
 **/
@Service
public class GoodSoftwareService {
    private static Logger logger = Logger.getLogger(GoodSoftwareService.class);
    @Autowired
    private GoodSoftwareDao goodSoftwareDao;


    /**
     * 查找精选软件的分类
     *
     * @return
     */
    public List<GoodSoftwareType> findSoftwareTypeService() {
        return goodSoftwareDao.findSoftwareTypeDao();
    }

    /**
     * 添加精选软件的信息
     *
     * @param rid
     * @param gid
     * @return
     */
    public boolean addGoodSoftwareService(String rid, String gid) {
        rid = rid.trim();
        gid = gid.trim();
        GoodSoftware goodSoftware = new GoodSoftware();
        goodSoftware.setId(DatabaseIdUtils.getDataId());
        goodSoftware.setRid(rid);
        goodSoftware.setGid(gid);
        goodSoftware.setCtime(new Date());
        return goodSoftwareDao.saveMassageDao(goodSoftware);
    }

    /**
     * 从精选中删除
     *
     * @param id
     * @return
     */
    public boolean deleteGoodSoftwareService(String id) {
        id = id.trim();

        return goodSoftwareDao.deleteGoodSoftwareDao(id);
    }


    public List<?> listGoodSoftwareService(String gid) {
        gid = gid.trim();
        return goodSoftwareDao.listGoodSoftwareDao(gid);
    }
}
